/*
 * Copyright (C) 2015 The Android Open Source Project
 * Copyright (C) 2015 Broadcom Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef ANDROID_INCLUDE_BT_IPSP_H
#define ANDROID_INCLUDE_BT_IPSP_H

__BEGIN_DECLS

typedef enum {
    BTIPSP_STATE_CONNECTED       = 0,
    BTIPSP_STATE_CONNECTING      = 1,
    BTIPSP_STATE_DISCONNECTED    = 2,
    BTIPSP_STATE_DISCONNECTING   = 3
} btipsp_connection_state_t;

typedef enum {
    BTIPSP_STATE_ENABLED = 0,
    BTIPSP_STATE_DISABLED = 1
} btipsp_control_state_t;

/**
* Callback for ipsp connection state
*/
typedef void (*btipsp_connection_state_callback)(btipsp_connection_state_t state, bt_status_t error,
                                                const bt_bdaddr_t *bd_addr);
typedef void (*btipsp_control_state_callback)(btipsp_control_state_t state, bt_status_t error, const char* ifname);

typedef struct {
    size_t size;
    btipsp_control_state_callback control_state_cb;
    btipsp_connection_state_callback connection_state_cb;
} btipsp_callbacks_t;

typedef struct {
    /** set to size of this struct*/
    size_t          size;
    /**
     * Initialize the ipsp interface and register the btipsp callbacks
     */
    bt_status_t (*init)(const btipsp_callbacks_t* callbacks);
    /*
     * enable/disable the ipsp board router service. The result state of
     * enabl will be returned by btipsp_control_state_callback. when is enabled,
     * the state of connecting ipspu device will be notified by btipsp_connection_state_callback
     */
    bt_status_t (*enable)(int enable);

    /**
     * start bluetooth ipsp connection to the remote ble node. The result state will be
     * returned by btipsp_connection_state_callback
     */
    bt_status_t (*connect)(const bt_bdaddr_t *bd_addr);
    /**
     * stop bluetooth ipsp connection. The result state will be returned by btipsp_connection_state_callback
     */
    bt_status_t (*disconnect)(const bt_bdaddr_t *bd_addr);

    /**
     * Cleanup the ipsp interface
     */
    void (*cleanup)(void);

} btipsp_interface_t;

__END_DECLS

#endif /* ANDROID_INCLUDE_BT_IPSP_H */
